* (c) M. Ciccarelli. Rats version 6.2
*
** program to compute persistence parameters and loading factor
** replicate tables 6-7. change sample at line 57
*
*
OPEN DATA forecast_DATA.xls
CALENDAR 1960 1 4
ALL 2008:02
DATA(FORMAT=XLS,ORG=COLUMNS)
close data
comp seas = 1

if seas ==1
{
X11(GRADUATE) CPIQU2 / CPIQU2
X11(GRADUATE) CPIQAT / CPIQAT
X11(GRADUATE) CPIQLU / CPIQLU
X11(GRADUATE) CPIQIT / CPIQIT
X11(GRADUATE) CPIQPT / CPIQPT
X11(GRADUATE) CPIQNL / CPIQNL
X11(GRADUATE) CPIQSE / CPIQSE
X11(GRADUATE) CPIQBE / CPIQBE
X11(GRADUATE) CPIQDE / CPIQDE
X11(GRADUATE) CPIQDK / CPIQDK
X11(GRADUATE) CPIQES / CPIQES
X11(GRADUATE) CPIQFI / CPIQFI
X11(GRADUATE) CPIQUK / CPIQUK
X11(GRADUATE) CPIQFR / CPIQFR
X11(GRADUATE) CPIQGR / CPIQGR
X11(GRADUATE) CPIQIE / CPIQIE
X11(GRADUATE) CPIQUS / CPIQUS
X11(GRADUATE) CPIQJP / CPIQJP
X11(GRADUATE) CPIQAU / CPIQAU
X11(GRADUATE) CPIQCA / CPIQCA
X11(GRADUATE) CPIQNZ / CPIQNZ
X11(GRADUATE) CPIQNO / CPIQNO
X11(GRADUATE) CPIQCH / CPIQCH
}
end if

comp n = 23
comp steps = 1
comp switch = 1

dec vec[series] infla(n)
dec vec[series] infla1(n)
dec vec[series] idio(n)

do i = 1,n
set infla(i) = (400./steps)*log(([series] i)/(([series] i){steps}))
end

source(noecho) princomp.src

** change here the sample to replicate the table
smpl 1960:1 2008:2 ;* 1960:1 1980:4 ;*  1980:1 1990:4 ;* 1990:1 2008:2

if switch==0
{
comp count = 1
   dofor jj = infla(1) infla(2) infla(3) infla(4) infla(5) infla(6) infla(7) infla(8) $
    infla(9) infla(10) infla(11) infla(12) infla(13) infla(14) infla(15) infla(16)$
    infla(17) infla(18) infla(19) infla(20) infla(21) infla(22) infla(23)
    stat(noprint) jj
    set infla1(count) = (([series] jj)-%mean)/sqrt(%variance)
    comp count = count+1
   end

  @PRINCOMP(Ncomp=1) / pcomp
  # infla1(1) infla1(2) infla1(3) infla1(4) infla1(5) infla1(6) infla1(7) infla1(8) $
    infla1(9) infla1(10) infla1(11) infla1(12) infla1(13) infla1(14) infla1(15) infla1(16)$
    infla1(17) infla1(18) infla1(19) infla1(20) infla1(21) infla1(22) infla1(23)


  set factor1 = (-1.)*pcomp(1)
}
else
{
set average = 0.0

do i = 1,n
set average = average+(1./n)*infla(i)
end
set factor1 = average
}
end if

Dec rec lambdas(n,2)
dec vec[series] fitted(n)

  do i = 1,n

  linreg(noprint) INFLA(i)
  # constant factor1
  PRJ FITTED(i)
  comp lambdas(i,1) = %beta(2)
  comp lambdas(i,2) = %stderrs(2)
  set idio(i) = infla(i)-fitted(i)

  end do i


dec rect rhos(n+1,2)

linreg(noprint) factor1
# factor1{1} constant
comp rhos(n+1,1) = %beta(1)
comp rhos(n+1,2) = %STDERRS(1)

  do i = 1,n

  linreg(noprint) idio(i)
  # idio(i){1}
  comp rhos(i,1) = %beta(1)
  comp rhos(i,2) = %STDERRS(1)
end

wri rhos













